<template>
  <div>
      <div style="width:500px;" align='center'>
        <van-cell-group inset>
            <van-field v-model="from.username" label="用户名" placeholder="请输入用户名" />
            <van-field v-model="from.password" label="密码" placeholder="请输入密  码" />
            <van-button type="primary" @click="login">登录</van-button>
        </van-cell-group>
    </div>
  </div>
</template>

<script>
import myaxios from 'axios'
export default {
    data(){
        return{
            from:{},
            id:1
        }
    },
    methods:{
        login(){
            myaxios({url:'http://127.0.0.1:5000/users',method:'post',data:this.from}).then(res=>{
                console.log(res)
                localStorage.setItem('id',this.id)
                localStorage.setItem('username',res.data.username)
                this.$toast.fail("欢迎你");
                this.$router.push({path:'/pymsqlzxc'})
            })    
        }
    }
}
</script>

<style>

</style>